local function read_file(file_name)
        if not file_name then
                return nil, "missing file_name"
        end
        local file = io.open(file_name,'r')
        if not file then
                return nil, "can\'t open file \"" .. file_name .. "\""
        end
        local content = file:read('*all')
        file:close()
        return content, nil
end
local function write_file(file_name, content)
        if not file_name then
                return nil, "missing file_name"
        end
        content = content or ''
        local file = io.open(file_name, "a")
        if not file then
                return "can\'t open file \"" .. file_name .. "\""
        end
        file:write(content.."\n")
        file:close()
end
local  pcip = ngx.shared.pcip
local  class = pcip:get("gclass")
local  hclass = "/home/yan/www/"..class
for i=101,160 do
        ip = "192.168.11."..i
        local name = pcip:get(ip)
        if name ~= nill
                then
                        local ipname = ip.." "..name
                        write_file(hclass, ipname)
                end
end
ngx.say("<!DOCTYPE html><html><head><meta charset=\"utf-8\"></head><body>",class,"<pre>" )
ngx.say(read_file(hclass))
ngx.say("</pre></html>")
